/**
 * @license
*
* PreProcessing is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PreProcessing is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PreProcessing.  If not, see <http://www.gnu.org/licenses/>.
* 
*/

package SmartGrid;

/**
 *
 * @author Ash
 */



public class Server {
    
    
    double Supply;
    double Demand;
    
    
    public double getTime()
    {
        //command to get time
        double CurrentTime = 14.23;
        return CurrentTime;
    }
         
    public static void createInvoice()
    {
        
        double OnPeakTariff = 0.75;
        double OffPeakTariff = 0.55;
        
        int OnPeakIndex = 0;
        int OnPeakCurrentRecord;
        int OnPeakTotalRecords = 5; //replace with command to get the number of records from the database
        int OnPeakTotalUse = 0;
        while (OnPeakIndex < OnPeakTotalRecords)
        {
            OnPeakCurrentRecord = 5; //replace with command to get the value of the record at index number that matches index (variable)
            OnPeakTotalUse = OnPeakTotalUse + OnPeakCurrentRecord;
            OnPeakIndex ++;
        }
        
        int OffPeakIndex = 0;
        int OffPeakCurrentRecord;
        int OffPeakTotalRecords = 5; //replace with command to get the number of records from the database
        int OffPeakTotalUse = 0;
        while (OffPeakIndex < OffPeakTotalRecords)
        {
            OffPeakCurrentRecord = 5; //replace with command to get the value of the record at index number that matches index (variable)
            OffPeakTotalUse = OffPeakTotalUse + OffPeakCurrentRecord;
            OffPeakIndex ++;
        }
        
        double OnPeakCharge = OnPeakTotalUse * OnPeakTariff;
        double OffPeakCharge = OffPeakTotalUse * OffPeakTariff;
        double TotalCharge = OnPeakCharge + OffPeakCharge;
        System.out.println  ("Charge for On Peak Use: $" + OnPeakCharge);
        System.out.println ("Charge for Off Peak Use: $" + OffPeakCharge);
        System.out.println ("Total Charge: $" + TotalCharge);
                
    }
    
    public boolean detectOverload()// method to check if overload occurs. If demand gets above 90% of supply, it will return a true boolean
    {
        //code to detect when there is an overload. needs method to receive the supply and demand, or maybe another method
        double Limit = Supply * 0.9; //the limit will be set at 90% of the total available supply
        
        if (Demand > Limit)//if demand is above limit (90% of supply)
        {
            return true; //return true
        }
        else //otherwise if not above limit
        {
            return false; //return false
        }
    }
}